package com.example.ercmssystem2.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CustomErrorController implements ErrorController {

    @GetMapping("/error")
    public String handleError() {
        return "error";
    }
    
    @GetMapping("/api/error")
    @ResponseBody
    public Map<String, Object> handleApiError() {
        Map<String, Object> response = new HashMap<>();
        response.put("status", "error");
        response.put("message", "API请求出错");
        return response;
    }
} 